import time


def now(bit: int = 10):
    if bit == 10:
        stamp = round(time.time())
    else:
        stamp = round(time.time() * 1000)
    return stamp

def now_datetime():
    return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())


def date_format(format_str: str, time_stamp: int):
    time_stamp = time.localtime(float(time_stamp))
    fm = (format_str.replace("yyyy", '%Y').replace("MM", '%m').replace("dd", '%d')
          .replace("HH", '%H').replace("mm", "%M").replace("ss", '%S'))
    return time.strftime(fm, time_stamp)